package com.lcf.system.feign;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.lcf.feign.dto.system.user.SysUserFeignDTO;
import com.lcf.feign.service.system.SysUserFeignService;
import com.lcf.system.entity.SysUser;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述：用户
 *
 * @author lcf
 * @since 2025/3/4 20:11
 */
@Hidden
@RestController
@RequestMapping("feign/user")
public class SysUserFeignServiceImpl implements SysUserFeignService {
    @Override
    @GetMapping("/{id}")
    public SysUserFeignDTO getUserById(@PathVariable Long id) {
        SysUser sysUser = Db.lambdaQuery(SysUser.class).eq(SysUser::getId, id).one();
        if (sysUser == null) {
            return null;
        }

        return BeanUtil.copyProperties(sysUser, SysUserFeignDTO.class);
    }
}
